package com.sugon.service;

import com.sugon.dao.SysUserDao;
import com.sugon.entity.SysUserEntity;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class ApiUserService {

    @Resource
    private SysUserDao userDao;

    /**
     * queryObject
     *
     * @param userId
     * @return
     */
    public SysUserEntity queryObject(String userId) {
        return userDao.queryObject(userId);
    }

    /**
     * queryList
     *
     * @param map
     * @return
     */
    public List<SysUserEntity> queryList(Map<String, Object> map) {
        return userDao.queryList(map);
    }

    /**
     * queryTotal
     *
     * @param map
     * @return
     */
    public int queryTotal(Map<String, Object> map) {
        return userDao.queryTotal(map);
    }

    /**
     * save
     *
     * @param mobile
     * @param password
     */
    public void save(String mobile, String password) {
        SysUserEntity user = new SysUserEntity();
        user.setUserName(mobile);
        user.setPassWord(DigestUtils.sha256Hex(password));
        userDao.save(user);
    }

    /**
     * save
     *
     * @param userVo
     */
    public void save(SysUserEntity userVo) {
        userDao.save(userVo);
    }

    /**
     * update
     *
     * @param user
     */
    public void update(SysUserEntity user) {
        userDao.update(user);
    }

    /**
     * delete
     *
     * @param userId
     */
    public void delete(Long userId) {
        userDao.delete(userId);
    }

    /**
     * deleteBatch
     *
     * @param userIds
     */
    public void deleteBatch(Long[] userIds) {
        userDao.deleteBatch(userIds);
    }
}
